package com.e3.basdoc.cust.client;

import java.util.List;

import com.e3.basdoc.cust.model.CustModel;
import com.e3.template.tgf.TGFTreePanelAsync;
import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * Description: <br>
 * 
 * @author: <a href="mailto:senton1101@126.com">TianXiangdong</a> 2010-7-27 上午11:15:50
 * @version: 1.0
 */
public class CustTreePanel extends TGFTreePanelAsync<CustModel> {

	private CustRPCServiceAsync service = CustRPCService.Util.getInstance();

	@Override
	public String getTreeDisplayFieldName() {
		return CustModel.NAME;
	}

	@Override
	public void onTreeLoadSuccess(CustModel parent, List<CustModel> result) {
		if(result!=null&&result.size()==1){
			CustModel model = result.get(0);
			if(CustHelper.INSTANCE.isRootModel(model)){
				model.setName(CustMessages.INSTANCE.tree_root_name());
			}
		}
	}

	@Override
	public void excuteLoadModelChildren(CustModel pModel,AsyncCallback<List<CustModel>> callback) {
		service.getCustChildren(pModel, callback);
	}

	@Override
	public String getRootDisplayName() {
		return CustMessages.INSTANCE.tree_root_name();
	}

	@Override
	protected boolean isRootModel(CustModel model) {
		return CustHelper.INSTANCE.isRootModel(model);
	}

}
